home *** CD-ROM | disk | FTP | other *** search
/ Zodiac 50 Game Pack 2 / Zodiac 50 Game Pack 2.iso / cardsws1 / solii.cdl < prev    next >
Text File  |  1993-09-22  |  6KB  |  275 lines

  1. //⌐ David Jean, 1993
  2. game solII is 37 by 20;
  3.  
  4. //A1 A2 A3 A4 B1 B2 B3 B4 C1
  5.  
  6. {--------------------------------------------------------------------------}
  7.  
  8. procedure About is
  9. begin
  10.   Clear 'About Solitaire II';
  11.   write('Rules from : ?.\n');
  12.   write('Program : ⌐ David Jean, 1993.\n');
  13. end;
  14.  
  15. stack A1;
  16. stack A2;
  17. stack A3;
  18. stack A4;
  19. stack B1;
  20. stack B2;
  21. stack B3;
  22. stack B4;
  23.  
  24. {****c1 et c2 sont de meme sorte et c1 est un de plus que c2}
  25. predicate Follow?(c1, c2 : card) is
  26.   return ((c1 / 13)=(c2 / 13)) and (c1=(c2+1));
  27.  
  28. {****verifie si c1 est un roi}
  29. predicate IsKing?(c1 : card) is
  30.   return (c1 mod 13)=King;
  31.  
  32. {****verifie si c1 est un roi}
  33. predicate IsAce?(c1 : card) is
  34.   return (c1 mod 13)=Ace;
  35.  
  36. {****c1 est une carte tournee vers le bas}
  37. predicate IsSideDown?(c1 : card) is 
  38.   return (c1 / DeckSize)=down;
  39.  
  40. predicate EmptySpot? is 
  41. begin
  42.   with it do
  43.     if it!=0 then return TRUE
  44.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  45.   return FALSE;
  46. end;
  47.  
  48. predicate IsIn?(fs : stack; c1 : card) is
  49. var i : integer;
  50. begin
  51.   i:=1;
  52.   while i<=fs! do
  53.     if fs[i]=c1 then
  54.       begin
  55.       flash fs[i];
  56.       return TRUE;
  57.       end
  58.     else i:=i+1;
  59.   return FALSE;
  60. end;
  61.  
  62. predicate KingIsIn?(fs : stack) is
  63. var i : integer;
  64.     r : boolean;
  65. begin
  66.   //on commence a 2 parce qu'on s'en fout si un roi est le premier d'une pile
  67.   i:=2;
  68.   r:=FALSE;
  69.   while i<=fs! do
  70.     begin
  71.     if not IsSideDown?(fs[i]) then
  72.       if IsKing?(fs[i]) then
  73.         begin
  74.         flash fs[i];
  75.         r:=TRUE;
  76.         end;
  77.     i:=i+1;
  78.     end;
  79.   return r;
  80. end;
  81.  
  82. predicate Visible?(fs : stack; c1 : card) is
  83. begin
  84.   with it do
  85.     if it<>fs then
  86.       if IsIn?(it,c1) then return TRUE
  87.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  88.   return FALSE;
  89. end;
  90.  
  91. predicate KingVisible?(fs : stack) is
  92. var r : boolean;
  93. begin
  94.   r:=FALSE;
  95.   with it do
  96.     if it<>fs then
  97.       if KingIsIn?(it) then r:=TRUE
  98.   for A1, A2, A3, A4, B1, B2, B3, B4;    
  99.   return r;
  100. end;
  101.  
  102. {--------------------------------------------------------------------------}
  103.  
  104. stack C1 is
  105.   X := 34;
  106.   Y := 2;
  107.   Direction := over;
  108.   W := 3;
  109.   H := 4;
  110.   //****************************
  111.   Start is
  112.     begin
  113.     Add Ace+Spade .. King+Diamond;
  114.     Turn [1..52] side down;
  115.     Shuffle;
  116.     end;
  117.   //****************************
  118.   Select(Spos : Index) is
  119.   var movepossible : boolean;
  120.     begin
  121.     movepossible:=FALSE;
  122.     with it do
  123.       if (it!=0) and KingVisible?(it) then movepossible:=TRUE
  124.       else if not IsAce?(it[it!]) and Visible?(it,it[it!]-1) then movepossible:=TRUE
  125.     for A1, A2, A3, A4, B1, B2, B3, B4;
  126.     if movepossible or (!=0) then break;
  127.     with it do
  128.       begin
  129.       Pull 1 to it;
  130.       Turn it[it!] side up;
  131.       end
  132.     for A1, A2, A3, A4;
  133.     end;
  134.   //****************************
  135.   Help is
  136.     begin
  137.     Clear 'The Stock';
  138.     Write('You can click here to move the four remaining cards to ');
  139.     Write('the first four pile on The Tableau.\n');
  140.     Write('It will work only if no move can be made on The Tableau.\n');
  141.     Write('If there are legal moves, they will flash.\n');    
  142.     Wait 'About...' About;
  143.     end;
  144. end C1;
  145.  
  146. {--------------------------------------------------------------------------}
  147.  
  148. stack A1 is
  149.   X := 2;
  150.   Y := 2;
  151.   Direction := down;
  152.   W := 3;
  153.   H := 18;
  154.   //****************************
  155.   Start is
  156.     begin
  157.     Pull 6 from C1;
  158.     Turn [1..6] side up;
  159.     Draw C1;
  160.     end;
  161.   //****************************
  162.   Select(Spos : Index) is
  163.     begin
  164.     if Spos>! then Spos:=!;
  165.     if IsSideDown?([Spos]) then break;
  166.     if IsKing?([Spos]) then
  167.       with it do
  168.         if (it!=0) then
  169.           begin
  170.           Pull !-Spos+1 to it;
  171.           break procedure;
  172.           end
  173.       for A1, A2, A3, A4, B1, B2, B3, B4      
  174.     else
  175.       with it do
  176.         if it<>self then
  177.           if Follow?(it[it!],[Spos]) then
  178.         begin
  179.             Pull !-Spos+1 to it;
  180.             break procedure; 
  181.             end
  182.       for A1, A2, A3, A4, B1, B2, B3, B4;
  183.     end;
  184.   //****************************
  185.   Help is
  186.     begin
  187.     Clear 'The Tableau';
  188.     Write('Each card played here must be of the same suit and be in descending ');
  189.     Write('sequence to the card on which it is played.\n');
  190.     Write('You can pick a card anywhere on The Tableau (if it is side up).\n');
  191.     Write('Every cards below the one you choose will move with it.\n\n');
  192.     Write('Only kings can be moved in an empty spot.\n\n');
  193.     Write('The goal is four piles of a unique suit beginning with The King and ending with The Ace.\n'); 
  194.     Wait 'About...' About;
  195.     end;
  196. end A1;
  197.  
  198. stack A2 from A1 is
  199.   X := 6;
  200.   Y := 2;
  201. end A2;
  202.  
  203. stack A3 from A1 is
  204.   X := 10;
  205.   Y := 2;
  206. end A3;
  207.  
  208. stack A4 from A1 is
  209.   X := 14;
  210.   Y := 2;
  211. end A4;
  212.  
  213. stack B1 from A1 is
  214.   X := 18;
  215.   Y := 2;
  216.   //****************************
  217.   Start is
  218.     begin
  219.     Pull 6 from C1;
  220.     Turn [3..6] side up;
  221.     Draw C1;
  222.     end;
  223. end B1;
  224.  
  225. stack B2 from B1 is
  226.   X := 22;
  227.   Y := 2;
  228. end B2;
  229.  
  230. stack B3 from B1 is
  231.   X := 26;
  232.   Y := 2;
  233. end B3;
  234.  
  235. stack B4 from B1 is
  236.   X := 30;
  237.   Y := 2;
  238. end B4;
  239.  
  240. {--------------------------------------------------------------------------}
  241.  
  242. predicate inorder?(it : stack) is
  243. var i : integer;
  244. begin
  245.   i:=13;
  246.   while i>1 do
  247.     begin
  248.     if not Follow?(it[i-1],it[i]) then return FALSE;
  249.     i:=i-1;
  250.     end;
  251.   return TRUE;
  252. end;
  253.  
  254. predicate win? is
  255. begin
  256.   with it do
  257.     if (it!=13) then
  258.       if not inorder?(it) then return FALSE
  259.       else 
  260.     else if (it!<>0) then return FALSE  
  261.   for A1, A2, A3, A4, B1, B2, B3, B4;      
  262.   return TRUE;
  263. end;
  264.  
  265. predicate Integrity? is
  266. begin
  267.   with it do
  268.     if it!>0 then
  269.       if IsSideDown?(it[it!]) then
  270.         Turn it[it!] side up
  271.   for B1, B2, B3, B4;
  272.   return TRUE;
  273. end;
  274.  
  275. order C1, A1, A2, A3, A4, B1, B2, B3, B4.